package com.block.channelext.factory;

import com.block.channelext.enums.ChannelEnum;
import com.block.channelext.service.IChannelHandleService;
import com.block.channelext.service.channel.*;
import com.block.common.util.ApplicationContextUtil;

import java.util.HashMap;
import java.util.Map;

public class ChannelFactory {

    private static Map<String, Class<? extends IChannelHandleService>> serviceMap = new HashMap<>();
    static {
        serviceMap.put(ChannelEnum.JIZHUN.getChannelCode(), JiZhunChannelHandleService.class);
        serviceMap.put(ChannelEnum.BAIDUFLOW.getChannelCode(), BaiDuFlowChannelHandleService.class);

        serviceMap.put(ChannelEnum.SUOZHI.getChannelCode(), SuoZhiFlowChannelHandleService.class);
        serviceMap.put(ChannelEnum.SUOZHI1.getChannelCode(), SuoZhiFlowChannelHandleService.class);

        serviceMap.put(ChannelEnum.BiANXIANMIAO.getChannelCode(), BianXianMaoFlowChannelHandleService.class);
        serviceMap.put(ChannelEnum.BiANXIANMIAO1.getChannelCode(), BianXianMaoFlowChannelHandleService.class);
        serviceMap.put(ChannelEnum.BiANXIANMIAO2.getChannelCode(), BianXianMaoFlowChannelHandleService.class);

        serviceMap.put(ChannelEnum.XIANGDIAN.getChannelCode(), XiangDianFlowChannelHandleService.class);


        serviceMap.put(ChannelEnum.AITUI.getChannelCode(), AiTuiFlowChannelHandleService.class);
        serviceMap.put(ChannelEnum.AITUI1.getChannelCode(), AiTuiFlowChannelHandleService.class);
        serviceMap.put(ChannelEnum.AITUI2.getChannelCode(), AiTuiFlowChannelHandleService.class);

        serviceMap.put(ChannelEnum.TUIA.getChannelCode(), TuiAFlowChannelHandleService.class);
    }

    public static IChannelHandleService getService(String filterKey){
        if (serviceMap.containsKey(filterKey)){
            Class<? extends IChannelHandleService> aClass = serviceMap.get(filterKey);
            return ApplicationContextUtil.getBean(aClass);
        }
        return ApplicationContextUtil.getBean(DefaultChannelHandleService.class);
    }
}

